# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  
  class CustomFormBuilder < ActionView::Helpers::FormBuilder
    (field_helpers + %w(submit date_select)).each do |selector|
      if selector == "submit"
        src = <<-ENDSTR
         def submit(field, options = {})
           @template.content_tag("tr",
           @template.content_tag("td", "<input type = submit value=" + field.to_s.humanize + "name = submit />") + 
           @template.content_tag("td", ""))
         end
        ENDSTR
      else
        src = <<-END_SRC
        def #{selector}(field, options = {})  
           @template.content_tag("tr",
           @template.content_tag("td", field.to_s.humanize + ":") + 
           @template.content_tag("td", super))
        end 
        END_SRC
      end
      
      class_eval src, __FILE__,__LINE__
    end
  end
    def custom_form_for(name, object = nil, options = nil, &proc)    
      concat("<table class='custom_form_for>'", proc.binding)   
        form_for (name,object,(options || {}).merge(:builder => CustomFormBuilder), &proc)
        concat("</table>", proc.binding)
    end
end
